from subprocess import Popen, PIPE

cmd =  ['ping', '-c', '1', '10.10.10.3']
ret = Popen(cmd, bufsize=1024, stdout=PIPE)
ret.wait()
echo = ret.communicate()[0].split('\n')
ttl_pos = echo[1].find('ttl')
print echo[1]
ms_pos = echo[1].find('ms')
i = ms_pos -2
while i > 0 and echo[1][i:i + 1].isdigit() == True or echo[1][i:i + 1] == "." :
    i -= 1
print echo[1][i+1:ms_pos]
# print echo[1][ttl_pos + 4:]
#
# t = ttl_pos  + 4
# while  echo[1][t:t+1].isdigit() == True:
#     t += 1
# print echo[1][ttl_pos+4 : t]


